package com.highspeed.bdk.controller.physical;

import com.bianmaba.spring.data.jpa.domain.Result;
import com.bianmaba.spring.mvc.method.support.annotations.JSON;
import com.highspeed.bdk.bean.entity.physical.MachineBox;
import com.highspeed.bdk.controller.base.BdkCrudController;
import com.highspeed.bdk.service.physical.IMachineBoxService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = {"machinebox"}, method = RequestMethod.POST)
@Api(tags = "机箱")
public class MachineBoxController extends BdkCrudController<MachineBox, Integer> {
    @Autowired
    private IMachineBoxService machineBoxService;

    @Override
    protected IMachineBoxService getService() {
        return machineBoxService;
    }

    @ApiOperation(value = "保存整个机箱配置", notes = "参数为JSON数据，在必要时可以调用此函数保存单个机箱配置;<br/>" +
            "机箱信息中必须包含：physicalTopology.id属性，不然不会与相关拓扑图关联（已经关联的则会断掉）;<br/>" +
            "数据中的链路信息不会被保存,需要单独调用physical_link\\save来保存;")
    @JSON
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @Override
    public Result save(@RequestBody @ApiParam(name = "entity") MachineBox entity) {
        return super.save(entity);
    }
}
